package May;

import java.util.Scanner;

public class Test10ArrayUsing01 {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7};
        System.out.print("数组的遍历数据为：");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]);
            if (i < arr.length - 1) {
                System.out.print(",");
            } else {
                System.out.print("接下来我将会筛选出质数,有以下质数：");
            }
        }
        int temp=0;
        for (int i = 1; i < arr.length; i++) {
            boolean flag=true;
            for(int j=2;j<i;j++){
                if(arr[i]%j==0){
                    flag=false;
                    break;
                }
            }
            if (flag){
                temp++;
                if (temp==1) {
                    System.out.print("["+arr[i]+",");
                } else if (temp==4) {
                    System.out.print(arr[i]+"]");

                }else {
                    System.out.print(arr[i]+",");
                }
            }
        }
        System.out.println(",一共有"+temp+"个质数");
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个数字，我将记录为起始值");
        int compare = sc.nextInt();
        System.out.println("请再输入一个数字我将记录为末尾值");
        int compare2= sc.nextInt();
        System.out.print("您输入的范围是[" + compare+","+compare2 + "],到该数为止有");

        for (int i = compare; i <= compare2; i++) {
            boolean flag=true;

        }
        System.out.print("以上质数。一共有"+temp+"个质数");
    }
}
